package source.model;

import source.model.type.*;

/**
 * This class will be the wrapper for all objects that exist at a certain position.
 * Returned by the data handler when a position query is run.
 * Uses booleans to tell what exists at any location, and the querier(sp?) can do its
 * work from there.
 * @author Sean Larson
 *
 */
public class Tile {
	
	private Terrain t;
	private boolean[] hasType;
	private int length;
	private int pid;
	
	public Tile() {
		length = GameObjectType.values().length;
		hasType = new boolean[length];
	}
	
	public boolean add( GameObject go ) {
		GameObjectType got = go.objectType();
		GameObjectType[] gots = GameObjectType.values();
		
		if ( got == GameObjectType.TERRAIN ) 
			t = (Terrain)go;
		for ( int i = 0; i < length; i++ ) {
			if ( gots[i] == got ) {
				hasType[i] = true;
				return true;
			}
		}
		return false;
	}	
	
	public Terrain getTerrain() {
		return t;
	}
	
	public boolean hasType( GameObjectType got ) {
		GameObjectType[] gots = GameObjectType.values();
		
		for ( int i=0; i < length; i++ ) {
			if ( gots[i] == got ) 
				return hasType[i];
		}
		
		return false;
	}
	
	public void setPID( int pid ) {
		this.pid = pid;
	}
	
	public int getPID( ) {
		return this.pid;
	}
}
